{% set pypi_name = 'python-freezerclient' %}
{% set upstream_version = upstream_version('4.2.0') %}
{% set rpm_release = '1' %}
{% set source = url_pypi() %}

Name:           {{ py2name() }}
Version:        {{ py2rpmversion() }}
Release:        {{ py2rpmrelease() }}
Summary:        Python API and CLI for OpenStack Freezer
License:        {{ license('Apache-2.0') }}
Group:          Development/Languages/Python
URL:            https://docs.openstack.org/{{ pypi_name }}
Source0:        {{ source }}
BuildRequires:  openstack-macros
BuildRequires:  {{ py3('cliff') }}
BuildRequires:  {{ py3('fixtures') }}
BuildRequires:  {{ py3('keystoneauth1') }}
BuildRequires:  {{ py3('mock') }}
BuildRequires:  {{ py3('oslo.serialization') }}
BuildRequires:  {{ py3('oslo.utils') }}
BuildRequires:  {{ py3('oslotest') }}
BuildRequires:  {{ py3('pbr') }}
BuildRequires:  {{ py3('python-subunit') }}
BuildRequires:  {{ py3('stestr') }}
BuildRequires:  {{ py3('testtools') }}
BuildArch:      noarch

%description
Client library for Freezer built on the Freezer API. It provides a Python API
(the freezerclient module) and a command-line tool (freezer).

%package -n python3-freezerclient
Summary:        Python API and CLI for OpenStack Freezer
Requires:       {{ py3('cliff') }}
Requires:       {{ py3('keystoneauth1') }}
Requires:       {{ py3('oslo.serialization') }}
Requires:       {{ py3('oslo.utils') }}
Requires:       {{ py3('pbr') }}
Requires:       {{ py3('six') }}
%if 0%{?suse_version}
Obsoletes:      {{ py2name(py_versions='py2') }} < 3.0.0
%endif

%description -n python3-freezerclient
Client library for Freezer built on the Freezer API. It provides a Python API
(the freezerclient module) and a command-line tool (freezer).

This package contains the Python 3.x module.

%package -n python-freezerclient-doc
Summary:        Documentation for OpenStack Freezer API client libary
Group:          Documentation/HTML
BuildRequires:  {{ py3('Sphinx') }}
BuildRequires:  {{ py3('openstackdocstheme') }}

%description -n python-freezerclient-doc
Client library for Freezer built on the Freezer API. It provides a Python API
(the freezerclient module) and a command-line tool (freezer).
This package contains the documentation.

%prep
%autosetup -p1 -n %{name}-%{version}
%py_req_cleanup

%build
%{py3_build}

# Build HTML docs and man page
PBR_VERSION={{ upstream_version }} %sphinx_build -b html doc/source doc/build/html
rm -r doc/build/html/.{doctrees,buildinfo}

%install
%{py3_install}

%check
python3 -m stestr.cli run

%files -n python3-freezerclient
%doc README.rst
%license LICENSE
%{python3_sitelib}/freezerclient
%{python3_sitelib}/*.egg-info
%{_bindir}/freezer

%files -n python-freezerclient-doc
%doc doc/build/html
%license LICENSE

%changelog
